#{include file="../Common/Header.html"}
<div class="layui-container fly-marginTop fly-user-main">
    #{include file="../Common/Nav.html"}
    <div class="fly-panel fly-panel-user" pad20>
        <div class="layui-tab layui-tab-brief" lay-filter="user">
            <ul class="layui-tab-title">
                <li><a href="/user/cash/index"><i class="layui-icon">&#xe659;</i> 硬币兑现</a></li>
                <li class="layui-this"><a href="/user/cash/record"><i class="layui-icon">&#xe63c;</i> 兑现记录</a></li>
            </ul>


            <div class="content-body">
                <form class="search-query"></form>
                <table id="cash"></table>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        layui.use([ 'hex', 'form'], function () {
            let table = $("#cash");
            let cao = layui.hex;
            let card = ['<span class="acg-badge acg-badge-light-primary">支付宝</span>', '<span class="acg-badge acg-badge-light-success">微信</span>', '<span class="acg-badge acg-badge-light-primary">钱包余额</span>'];
            let type = ['<span style="color: #0C84D1;">自动结算</span>', '<span style="color: #e8a430;">手动兑现</span>'];
            let status = ['<span class="acg-badge acg-badge-light-red">银行处理中</span>', '<span  class="acg-badge acg-badge-light-success">已到账</span>', '<span  class="acg-badge acg-badge-light">失败：[msg]</span>'];

            let queryParams = null;
            table.bootstrapTable({
                url:'/user/api/cash/record',//请求的url地址
                method: "post",//请求方式
                pageSize: 8,//每页显示的数量
                showRefresh: false,//是否显示刷新按钮
                cache: false,//是否使用缓存
                showToggle: false,//是否显示详细视图和列表视图的切换按钮
                cardView: false,
                pagination: true,//是否显示分页
                pageNumber: 1,//初始化显示第几页，默认第1页
                singleSelect: false,//复选框只能选择一条记录
                sidePagination: 'server',//分页显示方式，可以选择客户端和服务端（server|client）
                contentType: "application/x-www-form-urlencoded",//使用post请求时必须加上
                dataType: "json",//接收的数据类型
                queryParamsType: 'limit',//参数格式，发送标准的Restful类型的请求
                queryParams: function (params) {
                    params.page = (params.offset / params.limit) + 1;
                    if (queryParams) {
                        for (const key in params) {
                            queryParams[key] = params[key];
                        }
                    } else {
                        queryParams = params;
                    }
                    return queryParams;
                },
                //回调函数
                responseHandler: function (res) {
                    return {
                        "total": res.count,
                        "rows": res.data
                    }
                },
                columns: [
                    {
                        field: 'amount', title: '硬币', formatter: function (val, item) {
                            return '<b style="color: green;">￥' + item.amount + '</b>';
                        }
                    }
                    , {
                        field: 'type', title: '类型', formatter: function (val, item) {
                            return type[item.type];
                        }
                    }
                    , {
                        field: 'card', title: '到账方式', formatter: function (val, item) {
                            return card[item.card];
                        }
                    }
                    , {
                        field: 'status', title: '状态', formatter: function (val, item) {
                            return status[item.status].replace("[msg]", item.message);
                        }
                    }
                    ,
                    {
                        field: 'cost', title: '手续费', formatter: function (val, item) {
                            return '<span style="color: #13c2b3;">' + item.cost + '</span>';
                        }
                    }
                    , {
                        field: 'create_time', title: '提交时间'
                    }
                    , {
                        field: 'arrive_time', title: '到账时间', formatter: function (val, item) {
                            if (!item.arrive_time) {
                                return "-";
                            }
                            return item.arrive_time;
                        }
                    }
                ]
            });

            cao.query('.search-query', table, [
                {
                    title: "到账方式", name: "equal-card", type: "select", dict: [
                        {id: 0, name: "支付宝"},
                        {id: 1, name: "微信"},
                    ]
                }, {
                    title: "状态", name: "equal-status", type: "select", dict: [
                        {id: 0, name: "处理中"},
                        {id: 1, name: "成功"},
                        {id: 2, name: "失败"},
                    ]
                },
                {title: "开始时间", name: "betweenStart-create_time", type: "date"},
                {title: "结束时间", name: "betweenEnd-create_time", type: "date"},
            ], true, false);
        });
    });
</script>
#{include file="../Common/Footer.html"}
